-- Health Upgrade by Prefanatic for use with Atlantis Flavor.

UpgradeAdd("Health", "UpgradeHealth", [[Upgrade your health!]], 0, UpgradeHealth)

function UpgradeHealth(ply, target, isteam)
	if isteam == "true" then
		for k,v in pairs(player.GetAll()) do
			if v:Team() >= 10 and v:Team() < 19 and ply:Team() >= 10 and ply:Team() < 19 then
				
				if credits.Spend(v, 30) then
					Notify(v, "Your team leader has upgraded your health!", 5)
					
					PrevHealth = v:Health()
					
					v:SetHealth(PrevHealth + 600)
					v:SetNWBool("UPGRADE.HEALTH", true)
				else
					Notify(ply, "You do not have enough money to spend!", 5)
				end
			end
		end
	elseif isteam == "false" then
		for k,v in pairs(player.GetAll()) do
			if v:Nick() == tostring(target) then
				p = v
			end
		end
		
		if credits.Spend(p, 30) then
			Notify(v, "Your team leader has upgraded your health!", 5)
			
			PrevHealth = p:Health()
			
			p:SetHealth(PrevHealth + 600)
			p:SetNWBool("UPGRADE.HEALTH", true)
		else
			Notify(ply, "You do not have enough money to spend!", 5)
		end
	end
end